package com.solo;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "FirstServlet", value = "/FirstServlet")
public class FirstServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("UTF-8"); // 如果接收的请求数据是中文，设置请求编码
        String studentId = request.getParameter("studentId");
        String studentName = request.getParameter("studentName");

        Student student = new Student(studentId, studentName);
        request.setAttribute("student", student);

        request.getRequestDispatcher("/SecondServlet").forward(request, response);
    }
}